<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
class Admin extends CI_Controller
{
   public function __construct()
   {
      parent::__construct();
      $this->load->model('admin_model');
   }
   public function index()
   {
      if($this->auth->is_logged_in() == false)
      {
         $this->login();
      }
      else
      {
         $this->template->set('title','Selamat Datang | SIPMP Pesantren Zainul Hasan Genggong');
         $this->template->load('admin/login');
      }
   }
   public function login()
   {
      $this->load->library('form_validation');
      $this->form_validation->set_rules('email', 'Email', 'trim|required');
      $this->form_validation->set_rules('password', 'Password', 'trim|required');
      $this->form_validation->set_error_delimiters('<div class="loginmsg">', '</div>');
 
      if ($this->form_validation->run() == FALSE)
      {
      	 $data['title']="Selamat Datang Silahkan Login | SIPMP Pesantren Zainul Hasan Genggong";
         $this->load->view('admin/login',$data);
      }
      else
      {
         $email = $this->input->post('email');
         $password = $this->input->post('password');
         $success = $this->auth->do_login($email,$password);
         if($success)
         {
            // lemparkan ke halaman index user
   			$tingkat=$this->session->userdata('level');
   			if($tingkat=="1"){
               redirect('admin/dashboard_admin');
   			}elseif($tingkat=="2"){
   				redirect('admin/dashboard_pip');
   			}elseif($tingkat=="3"){
   				redirect('admin/dashboard_keamanan');
   			}elseif($tingkat=="4"){
               redirect('admin/dashboard_sekolah');
            }elseif($tingkat=="5"){
               redirect('admin/dashboard_walisantri');
               }else{
                  redirect('admin/login');
               }

         }else
         {
			     $data['title']="Login Error | SIPMP Pesantren Zainul Hasan Genggong";
            $data['login_info'] = "Maaf, Email dan Password salah!, Hubungi Kami jika anda lupa kata sandi";
            $this->load->view('admin/login',$data);
         }
      }
   }
   function logout(){
      $cx1=$this->session->set_userdata('id_user');
      $cx2=$this->session->set_userdata('nama_lengkap');
      $cx3=$this->session->set_userdata('level');
      $this->session->unset_userdata($cx3);
      $this->session->unset_userdata($cx2);
      $this->session->unset_userdata($cx1);
      redirect('admin/login');
   }
   //----- Komponen Kab Kec Dropdown -----/
   public function kab(){
    if('IS_AJAX') {
        $data['option_kab'] = $this->admin_model->getKabList();
        $this->load->view('admin/kab',$data);
    }
    }
   public function kec(){
    if('IS_AJAX') {
        $data['option_kec'] = $this->admin_model->getKecList();
        $this->load->view('admin/kec',$data);
    }
    }
    //------------- Start Code of Dashboard Admin --------------------------------/
   
   public function dashboard_admin()
   {  
      $this->auth->restrict();
      $data['title']="Halaman Administrator | SIPMP Pesantren Zainul Hasan Genggong";
	   $data['konten_view']='admin/dashboard/dashboard_admin';
		$this->load->view('admin/admin_view',$data);
   }
   public function dashboard_pip()
   {  
      $data['title']="Halaman Staff PIP | SIPMP Pesantren Zainul Hasan Genggong";
	   $data['konten_view']='admin/dashboard/dashboard_pip';
      $this->load->view('admin/admin_view',$data);  
   }
   public function dashboard_keamanan()
   {  
      $data['title']="Halaman Staff Keamanan| SIPMP Pesantren Zainul Hasan Genggong";
	  $data['konten_view']='admin/dashboard/dashboard_keamanan';
      $this->load->view('admin/admin_view',$data);
   }
   public function dashboard_sekolah()
   {
      $data['title']="Halaman Staff Sekolah | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/dashboard/dashboard_sekolah';
      $this->load->view('admin/admin_view_nosidebar',$data);
   }
   public function dashboard_walisantri()
   {  
      $data['title']="Halaman Staff Sekolah | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/dashboard/dashboard_admin';
      $this->load->view('admin/admin_view',$data);  
   }
   //----------------------Laporan PDF----------------------/

    public function laporan_psb_tahunan_pdf()
    {
    $this->load->library('fpdf');
    define('FPDF_FONTPATH',$this->config->item('fonts_path'));
    $tahu=date('Y');
    $query = $this->db->query("SELECT * from santri_baru where id_ta='$tahu'")->result();

    $data['hasil'] = $query;
    $data['nama_user']=$this->session->userdata('nama_lengkap');
    // Load view "pdf_rsantri_baru" untuk menampilkan hasilnya
    $this->load->view('admin/laporan/laporan_psb', $data);
    }
   //-------------------- PSB -----------------------------/
    

    public function func_salin_santri()
    {      
    $this->db->query('INSERT INTO santri (
  id_santri,
  nama_lengkap,
  nama_panggilan,
  tempat_lahir,
  tanggal_lahir,
  kelamin,
  catatan_kesehatan,
  warga_negara,
  alamat,
  propinsi,
  kabupaten,
  kecamatan,
  kode_pos,
  pendidikan_terakhir,
  tahun_lulus,
  sekolah_asal,
  alamat_sekolah,
  nama_wali,
  pekerjaan_wali,
  kontak_wali,
  alamat_wali,
  nama_ibu,
  pekerjaan_ibu,
  kontak_ibu,
  alamat_ibu,
  email,
  password,
  id_sekolah,
  id_ta
) 
SELECT 
  id_santri_baru,
  nama_lengkap,
  nama_panggilan,
  tempat_lahir,
  tanggal_lahir,
  kelamin,
  catatan_kesehatan,
  warga_negara,
  alamat,
  propinsi,
  kabupaten,
  kecamatan,
  kode_pos,
  pendidikan_terakhir,
  tahun_lulus,
  sekolah_asal,
  alamat_sekolah,
  nama_wali,
  pekerjaan_wali,
  kontak_wali,
  alamat_wali,
  nama_ibu,
  pekerjaan_ibu,
  kontak_ibu,
  alamat_ibu,
  email,
  password,
  id_sekolah,
  id_ta 
FROM
  santri_baru 
WHERE kelamin="Pria"');
    redirect('admin/santri');   
    }

   public function laporan_psb($ta)
   {      
         $data['homes'] = $this->admin_model->get_psb_lap($ta);
         $this->load->view('admin/excel/exp_santri_baru',$data);   
    }
   public function laporan_psb_lolos($ta)
   {      
         $data['homes'] = $this->admin_model->get_psb_lap_lolos($ta);
         $this->load->view('admin/excel/exp_santri_baru',$data);   
    }
   public function psb($id=NULL)
   {  

        $jml = $this->db->get('santri_baru');
        $config["base_url"] = base_url() . "admin/psb/";
        $config['total_rows'] = $jml->num_rows();
        $config['per_page'] = 15;
        $config['full_tag_open'] = '<ul class="pagination pagination-sm">';
        $config['full_tag_close'] = '</ul><!–pagination–>';
        $config['first_link'] = '&laquo; Awal';
        $config['first_tag_open'] = '<li class="page">';
        $config['first_tag_close'] = '</li>';
        $config['last_link'] = 'Akhir &raquo;';
        $config['last_tag_open'] = '<li class="page">';
        $config['last_tag_close'] = '</li>';
        $config['next_link'] = 'Selanjutnya &rarr;';
        $config['next_tag_open'] = '<li class="page">';
        $config['next_tag_close'] = '</li>';
        $config['prev_link'] = '&larr; Sebelumnya';
        $config['prev_tag_open'] = '<li class="page">';
        $config['prev_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li class="active"><a href="">';
        $config['cur_tag_close'] = '</a></li>';
        $config['num_tag_open'] = '<li class="page">';
        $config['num_tag_close'] = '</li>';
        $this->pagination->initialize($config);
        $data['halaman'] = $this->pagination->create_links();
        $data['homes'] = $this->admin_model->get_psb($config['per_page'], $id);
        $data['tahun'] = $this->admin_model->get_psb_ta();
      $data['title']="Manajemen Data Santri Baru | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/psb/psb';
      $this->load->view('admin/admin_view_nosidebar',$data);  

   }
      public function psb_ta($ta)
   {  
        $ids=NULL;
        $jml=$this->db->query("SELECT * FROM santri_baru where id_ta='$ta'");
        $config["base_url"] = base_url() . "admin/psb_ta/";
        $config['total_rows'] = $jml->num_rows();
        $config['per_page'] = 15;
        $config['full_tag_open'] = '<ul class="pagination pagination-sm">';
        $config['full_tag_close'] = '</ul><!–pagination–>';
        $config['first_link'] = '&laquo; Awal';
        $config['first_tag_open'] = '<li class="page">';
        $config['first_tag_close'] = '</li>';
        $config['last_link'] = 'Akhir &raquo;';
        $config['last_tag_open'] = '<li class="page">';
        $config['last_tag_close'] = '</li>';
        $config['next_link'] = 'Selanjutnya &rarr;';
        $config['next_tag_open'] = '<li class="page">';
        $config['next_tag_close'] = '</li>';
        $config['prev_link'] = '&larr; Sebelumnya';
        $config['prev_tag_open'] = '<li class="page">';
        $config['prev_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li class="active"><a href="">';
        $config['cur_tag_close'] = '</a></li>';
        $config['num_tag_open'] = '<li class="page">';
        $config['num_tag_close'] = '</li>';
        $this->pagination->initialize($config);
        $data['homes'] = $this->admin_model->get_psb_ta_halaman($ta,$config['per_page'],$ids);
        $data['tahun'] = $this->admin_model->get_psb_ta();
        $data['halaman'] = $this->pagination->create_links();
      $data['title']="Manajemen Data Santri Baru | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/psb/psb_ta';
      $this->load->view('admin/admin_view_nosidebar',$data);  

   }
   public function psb_tambah()
   {        $data['idBesar'] = $this->admin_model->getIdBesar();
      $data['option_propinsi'] = $this->admin_model->getPropinsiList();
      $data['option_sekolah'] = $this->admin_model->getSekolah();
      $data['title']="PSB Tambah| SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/psb/psb_tambah';
      $this->load->view('admin/admin_view',$data);  
   }
   public function cproc_psb_add(){
        $data=array('id_santri_baru'=>$this->input->post('id_baru'),
        'nama_lengkap'=>$this->input->post('nama_lengkap'),
        'nama_panggilan'=>$this->input->post('nama_panggilan'),
        'tempat_lahir'=>$this->input->post('tempat_lahir'),
        'tanggal_lahir'=>$this->input->post('tanggal_lahir'),
        'kelamin'=>$this->input->post('kelamin'),
        'catatan_kesehatan'=>$this->input->post('catatan_kesehatan'),
        'warga_negara'=>$this->input->post('warga_negara'),
        'alamat'=>$this->input->post('alamat'),
        'propinsi'=>$this->input->post('propinsi'),
        'kabupaten'=>$this->input->post('kabupaten'),
        'kecamatan'=>$this->input->post('kecamatan'),
        'kode_pos'=>$this->input->post('kode_pos'),
        'tahun_lulus'=>$this->input->post('tahun_lulus'),
        'sekolah_asal'=>$this->input->post('sekolah_asal'),
        'alamat_sekolah'=>$this->input->post('alamat_sekolah'),
        'nama_wali'=>$this->input->post('nama_wali'),
        'pekerjaan_wali'=>$this->input->post('pekerjaan_wali'),
        'kontak_wali'=>$this->input->post('kontak_wali'),
        'alamat_wali'=>$this->input->post('alamat_wali'),
        'nama_ibu'=>$this->input->post('nama_ibu'),
        'pekerjaan_ibu'=>$this->input->post('pekerjaan_ibu'),
        'kontak_ibu'=>$this->input->post('kontak_ibu'),
        'alamat_ibu'=>$this->input->post('alamat_ibu'),
        'email'=>$this->input->post('email'),
        'password'=>$this->input->post('id_baru'),
        'dokumen_lengkap'=>$this->input->post('dokumen_lengkap'),
        'pembayaran'=>$this->input->post('pembayaran'),
        'catatan'=>$this->input->post('catatan'),
         'tgl_reg'=>date("Y-m-d h:i:s"),
        'id_user'=>$this->input->post('id_user'),
        'id_sekolah'=>$this->input->post('id_sekolah'),
        'id_priode'=>$this->input->post('id_priode'),
        'id_ta'=>$this->input->post('id_ta'));
        $this->admin_model->minsert_psb($data);
        redirect('admin/psb');
      }
   public function psb_edit($id)
   {  $data['psb_edited']=$this->admin_model->get_psb_id($id);
      $data['option_propinsi'] = $this->admin_model->getPropinsiList();
      $data['option_sekolah'] = $this->admin_model->getSekolah();
      $data['title']="PSB | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/psb/psb_edit';
      $this->load->view('admin/admin_view_nosidebar',$data);  
   }
   public function cproc_psb_edit(){
        $id=$this->input->post('id');
        $nama_lengkap=$this->input->post('nama_lengkap');
        $nama_panggilan=$this->input->post('nama_panggilan');
        $tempat_lahir=$this->input->post('tempat_lahir');
        $tanggal_lahir=$this->input->post('tanggal_lahir');
        $kelamin=$this->input->post('kelamin');
        $catatan_kesehatan=$this->input->post('catatan_kesehatan');
        $warga_negara=$this->input->post('warga_negara');
        $alamat=$this->input->post('alamat');
        $propinsi=$this->input->post('propinsi');
        $kabupaten=$this->input->post('kabupaten');
        $kecamatan=$this->input->post('kecamatan');
        $kode_pos=$this->input->post('kode_pos');
        $tahun_lulus=$this->input->post('tahun_lulus');
        $sekolah_asal=$this->input->post('sekolah_asal');
        $alamat_sekolah=$this->input->post('alamat_sekolah');
        $nama_wali=$this->input->post('nama_wali');
        $pekerjaan_wali=$this->input->post('pekerjaan_wali');
        $kontak_wali=$this->input->post('kontak_wali');
        $alamat_wali=$this->input->post('alamat_wali');
        $nama_ibu=$this->input->post('nama_ibu');
        $pekerjaan_ibu=$this->input->post('pekerjaan_ibu');
        $kontak_ibu=$this->input->post('kontak_ibu');
        $alamat_ibu=$this->input->post('alamat_ibu');
        $email=$this->input->post('email');
        $password=$this->input->post('password');
        $dokumen_lengkap=$this->input->post('dokumen_lengkap');
        $pembayaran=$this->input->post('pembayaran');
        $catatan=$this->input->post('catatan');
        $last_change=date("Y-m-d h:i:s");
        $id_user=$this->input->post('id_user');
        $id_sekolah=$this->input->post('id_sekolah');
        $id_priode=$this->input->post('id_priode');
        $id_ta=$this->input->post('id_ta');
        $this->admin_model->medit_psb($id,$nama_lengkap,$nama_panggilan,$tempat_lahir,$tanggal_lahir,$kelamin,$catatan_kesehatan,$warga_negara,$alamat,$propinsi,$kabupaten,$kecamatan,$kode_pos,$tahun_lulus,$sekolah_asal,$alamat_sekolah,$nama_wali,$pekerjaan_wali,$kontak_wali,$alamat_wali,$nama_ibu,$pekerjaan_ibu,$kontak_ibu,$alamat_ibu,$email,$password,$dokumen_lengkap,$pembayaran,$catatan,$last_change,$id_user,$id_sekolah,$id_priode,$id_ta);
        redirect('admin/psb');
      }
   public function cproc_psb_hapus($id){

      $this->admin_model->mproc_psb_hapus($id);
      $this->session->set_flashdata('pesan', 'Data Sukses Dihapus');
      redirect('admin/psb');

   }
   public function psb_konfirmasi()
   {  
      $data['title']="PSB | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/psb/psb_konfirmasi';
      $this->load->view('admin/admin_view_nosidebar',$data);  
   }
   //------------------- Pelangaran Awal ---------------------------/
  public function lookup(){
 
     // memproses hasil pengetikan keyword pada form
     $keyword = $this->input->post('term');
     $data['response'] = 'false'; //mengatur default response
     $this->load->model('home_model'); // memanggil file model
     $query = $this->home_model->seek($keyword); //memanggil fungsi pencarian pada model
 
     if(! empty($query) ) {
          $data['response'] = 'true'; //mengatur response
          $data['message'] = array(); //membuat array
          foreach( $query as $row ){
           $data['message'][] = array('label' => $row->nama, 'value' => $row->nama); //mengisi array dengan record yang diperoleh
          }
 
     }
 
     //konstanta IS_AJAX
     if(IS_AJAX){
          echo json_encode($data); //mencetak json jika merupakan permintaan ajax
     }
     else {
         $this->load->view('home/index',$data); //memanggil file view dan mengisi data yg diperoleh
     }
 
    }
   public function pelanggaran()
   {  
      $data['title']="Manajemen Pelanggaran Santri | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/pelanggaran/pelanggaran';
      $this->load->view('admin/admin_view_nosidebar',$data);  
   }
   public function pelanggaran_tambah()
   {  
      $data['title']="Manajemen Pelanggaran Santri | SIPMP Pesantren Zainul Hasan Genggong";
      $data['pelanggaran_sip']=$this->admin_model->getDaftarPelanggaran();
      $data['konten_view']='admin/pelanggaran/pelanggaran_tambah';
      $this->load->view('admin/admin_view_nosidebar',$data);  
   }
   public function pelanggaran_edit()
   {  
      $data['title']="Manajemen Pelanggaran Santri | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/pelanggaran/pelanggaran_edit';
      $this->load->view('admin/admin_view_nosidebar',$data);  
   }
   //---------------------- Perizinan ------------------//


  public function perizinan($id=NULL)
   {  
      $jml = $this->db->get('perizinan');
      $config["base_url"] = base_url() . "admin/perizinan/";
      $config['total_rows'] = $jml->num_rows();
      $config['per_page'] = 10;
      $config['full_tag_open'] = '<ul class="pagination pagination-sm">';
      $config['full_tag_close'] = '</ul><!–pagination–>';
      $config['first_link'] = '&laquo; Awal';
      $config['first_tag_open'] = '<li class="page">';
      $config['first_tag_close'] = '</li>';
      $config['last_link'] = 'Akhir &raquo;';
      $config['last_tag_open'] = '<li class="page">';
      $config['last_tag_close'] = '</li>';
      $config['next_link'] = 'Selanjutnya &rarr;';
      $config['next_tag_open'] = '<li class="page">';
      $config['next_tag_close'] = '</li>';
      $config['prev_link'] = '&larr; Sebelumnya';
      $config['prev_tag_open'] = '<li class="page">';
      $config['prev_tag_close'] = '</li>';
      $config['cur_tag_open'] = '<li class="active"><a href="">';
      $config['cur_tag_close'] = '</a></li>';
      $config['num_tag_open'] = '<li class="page">';
      $config['num_tag_close'] = '</li>';
      $this->pagination->initialize($config);
      $data['halaman'] = $this->pagination->create_links();
      $data['homes'] = $this->admin_model->get_perizinan($config['per_page'], $id);
      $data['title']="Manajemen perizinan | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/perizinan/perizinan';
      $this->load->view('admin/admin_view_nosidebar',$data);  
   }
   public function perizinan_tambah()
   {  
      $data['option_kategori'] = $this->admin_model->getKategori();
      $data['title']="Manajemen perizinan | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/perizinan/perizinan_tambah';
      $this->load->view('admin/admin_view_nosidebar',$data);  
   }
   public function cproc_perizinan_add(){

      $id_perizinan=$this->input->post('id_perizinan');
      $judul_perizinan=$this->input->post('judul_perizinan');
      $isi_berita=$this->input->post('isi_berita');
      $kategori=$this->input->post('kategori');
      $tanggal_publish=date('Y-m-d H:i:s');
      $id_user=20140001;
      $this->admin_model->mproc_perizinan_add($id_perizinan,$judul_perizinan,$isi_berita,$kategori,$tanggal_publish,$id_user);
      redirect('admin/perizinan');
      }
   public function perizinan_edit($id)
   {  
      $data['perizinan_ed']=$this->admin_model->get_perizinan_id($id);
      $data['option_kategori'] = $this->admin_model->getKategori();
      $data['title']="Manajemen perizinan | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/perizinan/perizinan_edit';
      $this->load->view('admin/admin_view_nosidebar',$data);  
   }
   public function cproc_perizinan_edit(){
      $id=$this->input->post('id');
      $judul_perizinan=$this->input->post('judul_perizinan');
      $isi_berita=$this->input->post('isi_berita');
      $kategori=$this->input->post('kategori');
      $tanggal_ubah=date('Y-m-d H:i:s');
      $id_user=20140001;
      $this->admin_model->mproc_perizinan_edit($id,$judul_perizinan,$isi_berita,$kategori,$tanggal_ubah,$id_user);
      redirect('admin/perizinan');
      }
    public function cproc_perizinan_hapus($id){

      $this->admin_model->mproc_perizinan_hapus($id);
      $this->session->set_flashdata('pesan', 'Data Sukses Dihapus');
      redirect('admin/perizinan');

   }
   //-------------- Pengumuman -----------------------//
   public function pengumuman($id=NULL)
   {  
        $jml = $this->db->get('pengumuman');
        $config["base_url"] = base_url() . "admin/pengumuman/";
        $config['total_rows'] = $jml->num_rows();
        $config['per_page'] = 10;
        $config['full_tag_open'] = '<ul class="pagination pagination-sm">';
        $config['full_tag_close'] = '</ul><!–pagination–>';
        $config['first_link'] = '&laquo; Awal';
        $config['first_tag_open'] = '<li class="page">';
        $config['first_tag_close'] = '</li>';
        $config['last_link'] = 'Akhir &raquo;';
        $config['last_tag_open'] = '<li class="page">';
        $config['last_tag_close'] = '</li>';
        $config['next_link'] = 'Selanjutnya &rarr;';
        $config['next_tag_open'] = '<li class="page">';
        $config['next_tag_close'] = '</li>';
        $config['prev_link'] = '&larr; Sebelumnya';
        $config['prev_tag_open'] = '<li class="page">';
        $config['prev_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li class="active"><a href="">';
        $config['cur_tag_close'] = '</a></li>';
        $config['num_tag_open'] = '<li class="page">';
        $config['num_tag_close'] = '</li>';
        $this->pagination->initialize($config);
        $data['halaman'] = $this->pagination->create_links();
        $data['homes'] = $this->admin_model->get_pengumuman($config['per_page'], $id);
      $data['title']="Manajemen Pengumuman | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/pengumuman/pengumuman';
      $this->load->view('admin/admin_view_nosidebar',$data);  
   }
   public function pengumuman_tambah()
   {  
      $data['option_kategori'] = $this->admin_model->getKategori();
      $data['title']="Manajemen Pengumuman | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/pengumuman/pengumuman_tambah';
      $this->load->view('admin/admin_view_nosidebar',$data);  
   }
   public function cproc_pengumuman_add(){

      $id_pengumuman=$this->input->post('id_pengumuman');
      $judul_pengumuman=$this->input->post('judul_pengumuman');
      $isi_berita=$this->input->post('isi_berita');
      $kategori=$this->input->post('kategori');
      $tanggal_publish=date('Y-m-d H:i:s');
      $id_user=20140001;
         $this->admin_model->mproc_pengumuman_add($id_pengumuman,$judul_pengumuman,$isi_berita,$kategori,$tanggal_publish,$id_user);
         //echo "process_update($id,$kd_brg,$judul_pengumuman,$isi_berita,$kategori,$tglmsk,$jml_brg,$hrg)";
         redirect('admin/pengumuman');
      }
   public function pengumuman_edit($id)
   {  
      $data['pengumuman_ed']=$this->admin_model->get_pengumuman_id($id);
      $data['option_kategori'] = $this->admin_model->getKategori();
      $data['title']="Manajemen Pengumuman | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/pengumuman/pengumuman_edit';
      $this->load->view('admin/admin_view_nosidebar',$data);  
   }
   public function cproc_pengumuman_edit(){
      //$this->load->library('form_validation');
      $id=$this->input->post('id');
      $judul_pengumuman=$this->input->post('judul_pengumuman');
      $isi_berita=$this->input->post('isi_berita');
      $kategori=$this->input->post('kategori');
      $tanggal_ubah=date('Y-m-d H:i:s');
      $id_user=20140001;
      /*$this->form_validation->set_rules('kd_brg','Kode barang','required');
      $this->form_validation->set_rules('judul_pengumuman','nama barang','required');
      $this->form_validation->set_rules('isi_berita','isi_berita Barang','required');
      $this->form_validation->set_rules('tglmsk','tanggal masuk',' required');
      $this->form_validation->set_rules('kategori','kategori barang','required');
      $this->form_validation->set_rules('jml_brg','jumlah barang','required');
      $this->form_validation->set_rules('hrg','harga','required');
      if ($this->form_validation->run()==false){
         $this->edit_data($id);
      }else{*/

         $this->admin_model->mproc_pengumuman_edit($id,$judul_pengumuman,$isi_berita,$kategori,$tanggal_ubah,$id_user);

         //echo "process_update($id,$kd_brg,$judul_pengumuman,$isi_berita,$kategori,$tglmsk,$jml_brg,$hrg)";

         redirect('admin/pengumuman');

         

         //}

      }
    public function cproc_pengumuman_hapus($id){

      $this->admin_model->mproc_pengumuman_hapus($id);
      $this->session->set_flashdata('pesan', 'Data Sukses Dihapus');
      redirect('admin/pengumuman');

   }
   //--------------- Start Code Halaman  -------------/
      public function halaman()
   {  
      $data['homes'] = $this->admin_model->get_halaman();
      $data['title']="Manajemen Halaman | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/halaman/halaman';
      $this->load->view('admin/admin_view_nosidebar',$data);  
   }
   public function halaman_tambah()
   {  
      $data['option_kategori'] = $this->admin_model->getKategori();
      $data['title']="Manajemen halaman | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/halaman/halaman_tambah';
      $this->load->view('admin/admin_view_nosidebar',$data);  
   }
   public function cproc_halaman_add(){

      $id_halaman=$this->input->post('id_halaman');
      $judul_halaman=$this->input->post('judul_halaman');
      $isi_berita=$this->input->post('isi_berita');
      $kategori=$this->input->post('kategori');
      $tanggal_publish=date('Y-m-d H:i:s');
      $id_user=20140001;
         $this->admin_model->mproc_halaman_add($id_halaman,$judul_halaman,$isi_berita,$kategori,$tanggal_publish,$id_user);
         //echo "process_update($id,$kd_brg,$judul_halaman,$isi_berita,$kategori,$tglmsk,$jml_brg,$hrg)";
         redirect('admin/halaman');
      }
   public function halaman_edit($id)
   {  
      $data['halaman_ed']=$this->admin_model->get_halaman_id($id);
      $data['title']="Manajemen halaman | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/halaman/halaman_edit';
      $this->load->view('admin/admin_view_nosidebar',$data);  
   }
   public function cproc_halaman_edit(){
      //$this->load->library('form_validation');
      $id=$this->input->post('id');
      $judul_halaman=$this->input->post('judul_halaman');
      $isi_halaman=$this->input->post('isi_halaman');
      $log_ubah=$this->input->post('log_ubah');
      /*$this->form_validation->set_rules('kd_brg','Kode barang','required');
      $this->form_validation->set_rules('judul_halaman','nama barang','required');
      $this->form_validation->set_rules('isi_berita','isi_berita Barang','required');
      $this->form_validation->set_rules('tglmsk','tanggal masuk',' required');
      $this->form_validation->set_rules('kategori','kategori barang','required');
      $this->form_validation->set_rules('jml_brg','jumlah barang','required');
      $this->form_validation->set_rules('hrg','harga','required');
      if ($this->form_validation->run()==false){
         $this->edit_data($id);
      }else{*/

         $this->admin_model->mproc_halaman_edit($id,$judul_halaman,$isi_halaman,$log_ubah);

         //echo "process_update($id,$kd_brg,$judul_halaman,$isi_berita,$kategori,$tglmsk,$jml_brg,$hrg)";

         redirect('admin/halaman');

         

         //}

      }
   //-------------------- Kategori -----------/
    
    
       public function kategori($id=NULL)
   {  
        $jml = $this->db->get('kategori');
        $config["base_url"] = base_url() . "admin/kategori/";
        $config['total_rows'] = $jml->num_rows();
        $config['per_page'] = 5;
        $config['full_tag_open'] = '<ul class="pagination pagination-sm">';
        $config['full_tag_close'] = '</ul><!–pagination–>';
        $config['first_link'] = '&laquo; Awal';
        $config['first_tag_open'] = '<li class="page">';
        $config['first_tag_close'] = '</li>';
        $config['last_link'] = 'Akhir &raquo;';
        $config['last_tag_open'] = '<li class="page">';
        $config['last_tag_close'] = '</li>';
        $config['next_link'] = 'Selanjutnya &rarr;';
        $config['next_tag_open'] = '<li class="page">';
        $config['next_tag_close'] = '</li>';
        $config['prev_link'] = '&larr; Sebelumnya';
        $config['prev_tag_open'] = '<li class="page">';
        $config['prev_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li class="active"><a href="">';
        $config['cur_tag_close'] = '</a></li>';
        $config['num_tag_open'] = '<li class="page">';
        $config['num_tag_close'] = '</li>';
        $this->pagination->initialize($config);
        $data['halaman'] = $this->pagination->create_links();
        $data['homes'] = $this->admin_model->get_kategori($config['per_page'], $id);
      $data['title']="Manajemen kategori | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/kategori/kategori';
      $this->load->view('admin/admin_view_nosidebar',$data);  
   }
   public function kategori_tambah()
   {  
      $data['option_kategori'] = $this->admin_model->getKategori();
      $data['title']="Manajemen kategori | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/kategori/kategori_tambah';
      $this->load->view('admin/admin_view_nosidebar',$data);  
   }
   public function cproc_kategori_add(){

      $id_kategori=$this->input->post('id_kategori');
      $nama_kategori=$this->input->post('nama_kategori');
         $this->admin_model->mproc_kategori_add($id_kategori,$nama_kategori);
         //echo "process_update($id,$kd_brg,$judul_kategori,$isi_berita,$kategori,$tglmsk,$jml_brg,$hrg)";
         redirect('admin/kategori');
      }
   public function kategori_edit($id)
   {  
      $data['kategori_ed']=$this->admin_model->get_kategori_id($id);
      $data['title']="Manajemen kategori | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/kategori/kategori_edit';
      $this->load->view('admin/admin_view_nosidebar',$data);  
   }
   public function cproc_kategori_edit(){
      //$this->load->library('form_validation');
      $id=$this->input->post('id');
      $nama_kategori=$this->input->post('nama_kategori');
      /*$this->form_validation->set_rules('kd_brg','Kode barang','required');
      $this->form_validation->set_rules('judul_kategori','nama barang','required');
      $this->form_validation->set_rules('isi_berita','isi_berita Barang','required');
      $this->form_validation->set_rules('tglmsk','tanggal masuk',' required');
      $this->form_validation->set_rules('kategori','kategori barang','required');
      $this->form_validation->set_rules('jml_brg','jumlah barang','required');
      $this->form_validation->set_rules('hrg','harga','required');
      if ($this->form_validation->run()==false){
         $this->edit_data($id);
      }else{*/

         $this->admin_model->mproc_kategori_edit($id,$nama_kategori);

         //echo "process_update($id,$kd_brg,$judul_kategori,$isi_berita,$kategori,$tglmsk,$jml_brg,$hrg)";

         redirect('admin/kategori');

         
         //}

      }
    public function cproc_kategori_hapus($id){

      $this->admin_model->mproc_kategori_hapus($id);
      redirect('admin/kategori');

   }
    
    
    
    
   //-------------- End Of Lembaga -------/
   public function lembaga()
   {  
      $data['title']="Manajemen Lembaga | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/lembaga/lembaga';
      $this->load->view('admin/admin_view',$data);  
   }
   public function lembaga_tambah()
   {  
      $data['title']="Manajemen Lembaga | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/lembaga/lembaga_tambah';
      $this->load->view('admin/admin_view',$data);  
   }
   public function lembaga_edit()
   {  
      $data['title']="Manajemen Lembaga | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/lembaga/lembaga_edit';
      $this->load->view('admin/admin_view',$data);  
   }
   public function user()
   {  
      $data['title']="Manajemen User | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/user/user';
      $this->load->view('admin/admin_view',$data);  
   }
   public function user_tambah()
   {  
      $data['title']="Manajemen User | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/user/user_tambah';
      $this->load->view('admin/admin_view',$data);  
   }
   public function user_edit()
   {  
      $data['title']="Manajemen User | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/user/user_edit';
      $this->load->view('admin/admin_view',$data);  
   }
   public function santri()
   {  
      $data['title']="Manajemen Data Santri | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/santri/santri';
      $this->load->view('admin/admin_view',$data);  
   }
   public function santri_tambah()
   {  
      $data['title']="Manajemen Data Santri | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/santri/santri_tambah';
      $this->load->view('admin/admin_view',$data);  
   }
   public function santri_edit()
   {  
      $data['title']="Manajemen Data Santri | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/santri/santri_edit';
      $this->load->view('admin/admin_view',$data);  
   }
   public function priode()
   {  
      $data['title']="Manajemen Priode Daftar | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/priode/priode';
      $this->load->view('admin/admin_view',$data);  
   }
   public function priode_tambah()
   {  
      $data['title']="Manajemen Priode Daftar | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/priode/priode_tambah';
      $this->load->view('admin/admin_view',$data);  
   }
   public function priode_edit()
   {  
      $data['title']="Manajemen Priode Daftar | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/priode/priode_edit';
      $this->load->view('admin/admin_view',$data);  
   }
   public function ta()
   {  
      $data['title']="Manajemen Tahun Ajaran | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/ta/ta';
      $this->load->view('admin/admin_view',$data);  
   }
   public function ta_tambah()
   {  
      $data['title']="Manajemen Tahun Ajaran | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/ta/ta_tambah';
      $this->load->view('admin/admin_view',$data);  
   }
   public function ta_edit()
   {  
      $data['title']="Manajemen Tahun Ajaran | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/ta/ta_edit';
      $this->load->view('admin/admin_view',$data);  
   }            
   public function konfigurasi()
   {  
      $data['title']="Manajemen konfigurasi | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/konfigurasi/konfigurasi';
      $this->load->view('admin/admin_view',$data);  
   }
   public function laporan()
   {  
      $data['title']="Manajemen Laporan | SIPMP Pesantren Zainul Hasan Genggong";
      $data['konten_view']='admin/laporan/laporan';
      $this->load->view('admin/admin_view',$data);  
   } 


}
